# -*- coding: utf-8 -*-
'''
Created on 2013-4-3

@author: chenkaode@baidu.com
'''

from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4 import uic
from PyQt4 import QtCore, QtGui
import sys
import ui_pathSelect

class PathSelectDlg(QDialog,ui_pathSelect.Ui_selectPathDialog):
    def __init__(self,parent=None):
        super(PathSelectDlg,self).__init__(parent)
        self.setupUi(self)
        self.native = QtGui.QCheckBox()
        self.native.setText("Use native file dialog.")
        self.native.setChecked(True)
        if sys.platform not in ("win32", "darwin"):
            self.native.hide()
        self.imgPath = ''
        self.path = ''
        self.connect(self.selectPathButton,SIGNAL("clicked()"),self.selectImgPath)
        self.connect(self.acceptButton,SIGNAL("clicked()"),self.acceptPath)
        
    def selectImgPath(self):    
        options = QtGui.QFileDialog.Options()
        if not self.native.isChecked():
            options |= QtGui.QFileDialog.DontUseNativeDialog
        self.path = QtGui.QFileDialog.getExistingDirectory(self, caption=QString())
    
    def acceptPath(self):
        self.imgPath = self.path
        self.close()
        